package com.binfenhulian.chinaenergy.ces.crawler.pipeline;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

import javax.annotation.Resource;

/**
 * Created by wanghjbuf on 2018/3/10.
 */
@Slf4j
@Scope("prototype")
@Component("com.binfenhulian.chinaenergy.ces.crawler.store.DefPipeline")
public class DefPipeline implements Pipeline {

    @Resource(name = "com.binfenhulian.chinaenergy.ces.crawler.pipeline.impl.DbServiceImpl")
    PersistentService persistentService;

    /**
     * 持久化爬取数据
     * @param resultItems
     * @param task
     */
    @Override
    public  void process(ResultItems resultItems, Task task) {
        persistentService.doStore(resultItems);
    }
}